﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BigNumber.NUnitTests
{
  internal static class TestsHelper
  {
    public static int TEST_COUNT = 10000;

    private static Random m_Random = new Random();

    /// <summary>
    /// Generates a string that represents a random number.
    /// </summary>
    /// <param name="digitLength">The number of digits in the random number</param>
    /// <param name="zeroChance">The probability in percent that the output will be the number 0 (100 = always 0, 0 = Never 0 )</param>
    /// <returns></returns>
    internal static string GenerateRandomNumber(int digitLength, int zeroChance)
    {
      if (zeroChance > 0 && m_Random.Next(100-zeroChance) == 0)
        return "0";
      StringBuilder result = new StringBuilder(m_Random.Next(1, 10).ToString());
      int realDigitLength = m_Random.Next(digitLength) + 1;
      for (int i = 1; i < realDigitLength; i++)
      {
        if (i==1)
          result.Append(m_Random.Next(1, 10).ToString());
        else
          result.Append(m_Random.Next(0, 10).ToString());
      }
      if (m_Random.Next(2) == 0)
        result.Insert(0, '-');
      return result.ToString();
    }

  }
}
